# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=libgnurx

pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.5.1
pkgrel=2
arch=('any')
pkgdesc="libgnurx (mingw-w64)"
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
options=('staticlibs')
license=('LGPL')
url="http://mingw.sourceforge.net/"
source=("http://download.sourceforge.net/mingw/Other/UserContributed/regex/mingw-regex-${pkgver}/mingw-libgnurx-${pkgver}-src.tar.gz"
    "mingw-w64-libgnurx-honor-destdir.patch"
    "mingw32-libgnurx-Makefile.am"
    "mingw32-libgnurx-configure.ac")
md5sums=('35c8fed3101ca1f253e9b6b1966661f6'
         '2d87c59177adf5ec13dbcc02acc4a450'
         'fb5cd6f2441d127b654d2e4cd1e0a11f'
         '63f3ec2dc36d1d1b8450e61dcb6e09fc')

prepare() {
  cd "$srcdir/mingw-libgnurx-${pkgver}"
  patch -Np0 -i $srcdir/mingw-w64-libgnurx-honor-destdir.patch
  
  cp $srcdir/mingw32-libgnurx-configure.ac configure.ac
  cp $srcdir/mingw32-libgnurx-Makefile.am Makefile.am
  touch NEWS
  touch AUTHORS
  libtoolize --copy
  aclocal
  autoconf
  automake --add-missing
}

build()
{
  mkdir -p $srcdir/build-${CARCH} && cd $srcdir/build-${CARCH}
  ../mingw-libgnurx-${pkgver}/configure \
      --prefix=${MINGW_PREFIX} \
      --host=${MINGW_CHOST}
  make
}

package()
{
  cd "$srcdir/build-${CARCH}"
  mkdir -p "${pkgdir}${MINGW_PREFIX}"/include
  make install DESTDIR="$pkgdir"
  cp -f ${pkgdir}${MINGW_PREFIX}/lib/libgnurx.dll.a ${pkgdir}${MINGW_PREFIX}/lib/libregex.dll.a
  cp -f ${pkgdir}${MINGW_PREFIX}/lib/libgnurx.a ${pkgdir}${MINGW_PREFIX}/lib/libregex.a
}

